#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import requests

from protobuf import common_pb2 as common


def main():
    url = 'http://127.0.0.1:8000/proto'
    headers = {'Content-Type': 'application/octet-stream'}
    req = common.BidRequest()
    req.requestId = 'jim'
    req.command = 'coding'
    st = req.SerializeToString()
    print(st)
    res = requests.post(url, headers=headers, data=st)
    print(res.headers)
    print('data {0} {1}'.format(res.status_code, res.content))
    resp = common.BidResponse()
    resp.ParseFromString(res.content)
    print('res {0} [{1}]'.format(resp.status, resp.msg))


if __name__ == "__main__":
    main()